<?php
defined('BASEPATH') or exit('No direct script access allowed');

/**
 * @model 基础controller，用于登录验证及数据获取
 */
class BasicController extends Comm_Controller
{

    public function __construct()
    {
        try {
            parent::__construct();
            $this->load->service("PService/LoginService");
            $this->load->service("PService/AccountService");
            $this->load->service("SService/EmailService");
        } catch (\TPException $e) {
            exit($e->getRetJson());
        }
    }


    /**
     * 方法名 function
     * 
    * @Name 获取方法列和角色方法列
    * @Desc 方法描述
    * @OpenFlag 是否开放,1开放0权限控制
    * @Author      DJC
    * @Date 2022-02-14 19:00:17
    * @return      [type]                   [description]
    */
    public function Sendemail(){
        $ret = $this->EmailService->Sendemail($_POST);
        exit(retSucc($ret));
    }




    /**
     * [adminLogin description]
     * @Name        后台登录
     * @Desc        方法描述
     * @Author      FengPQ
     * @DateTime    2020-08-11T21:50:56+0800
     * @OpenFlag:   1
     * @return      [type]                   [description]
     */
    public function adminLogin()
    {
        //登录操作
        $this->LoginService->login($_POST['usercode'], $_POST['password'], $_POST['type']);
        //获取基础数据
        $data['accountInfo'] = $this->AccountService->getAdminInfo($_SESSION[SESS_UUID]);

        $this->LoginService->saveLoginHistory();
        // 退出当前账户
//        $this->LoginService->destory_login($_SESSION[SESS_UUID]);
        exit(retSucc($data));
    }




    /**
     * [custLogin description]
     * @Name        前台用户登录
     * @Description 方法描述
     * @Author      FengPQ
     * @DateTime    2020-08-11T21:51:30+0800
     * @OpenFlag:   1
     * @return      [type]                   [description]
     */
    public function custLogin()
    {
        $this->LoginService->login($_POST['usercode'], $_POST['password'], AccountType::Cust[TPEnum::Value]);
        exit(retSucc());
    }

    /**
     * [test2 description]
     * @Name        方法名【简短】
     * @Description 方法描述
     * @Author      FengPQ
     * @DateTime    2020-08-11T21:51:49+0800
     * @OpenFlag:   是否开放，1开放0角色控制
     * @return      [type]                   [description]
     */
    public function test2()
    {
        echo __DIR__;
    }

    public function test()
    {
        require_once "../admin/";

        $class_name = 'AccountController';
        $reflection = new ReflectionClass($class_name);

        $methods = $reflection->getMethods();
        foreach ($methods as $method) {
            echo $method->name;
            echo '[' . $method->getDocComment() . ']';
            echo "</br>";
        }

    }

    private function getDescription($comment)
    {

    }


}
